<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sets write file buffering on the given stream</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.stream-set-timeout.html">stream_set_timeout</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.stream-socket-accept.html">stream_socket_accept</a></div>
 <div class="up"><a href="ref.stream.html">Stream 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.stream-set-write-buffer" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_set_write_buffer</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">stream_set_write_buffer</span> &mdash; <span class="dc-title">Sets write file buffering on the given stream</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-set-write-buffer-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>stream_set_write_buffer</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$stream</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$buffer</code></span>
   )</div>

  <p class="para rdfs-comment">
   Sets the buffering for write operations on the given <em><code class="parameter">stream</code></em>
   to <em><code class="parameter">buffer</code></em> bytes.
  </p>
  <p class="simpara">
   Output using <span class="function"><a href="function.fwrite.html" class="function">fwrite()</a></span> is normally buffered at
   8K.  This means that if there are two processes wanting to write
   to the same output stream (a file), each is paused after 8K of
   data to allow the other to write.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-set-write-buffer-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">stream</code></em></dt>

     <dd>

      <p class="para">
       The file pointer.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">buffer</code></em></dt>

     <dd>

      <p class="para">
       The number of bytes to buffer. If <em><code class="parameter">buffer</code></em>
       is 0 then write operations are unbuffered.  This ensures that all writes
       with <span class="function"><a href="function.fwrite.html" class="function">fwrite()</a></span> are completed before other processes are
       allowed to write to that output stream.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-set-write-buffer-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns 0 on success, or <acronym title="End Of File">EOF</acronym> if the request cannot be honored.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.stream-set-write-buffer-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3937">
    <p><strong>Example #1 <span class="function"><strong>stream_set_write_buffer()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     The following example demonstrates how to use
     <span class="function"><strong>stream_set_write_buffer()</strong></span> to create an unbuffered stream.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"w"</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">stream_set_write_buffer</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$output</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-set-write-buffer-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.fopen.html" class="function" rel="rdfs-seeAlso">fopen()</a> - 打开文件或者 URL</span></li>
   <li class="member"><span class="function"><a href="function.fwrite.html" class="function" rel="rdfs-seeAlso">fwrite()</a> - 写入文件（可安全用于二进制文件）</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.stream-set-timeout.html">stream_set_timeout</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.stream-socket-accept.html">stream_socket_accept</a></div>
 <div class="up"><a href="ref.stream.html">Stream 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
